package com.saku.uiproject;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        setHorizontalRecyclerView();
    }

    private void setHorizontalRecyclerView() {
        int[] resIds = {
                R.drawable.betty,
                R.drawable.cake,
                R.drawable.flowers,
                R.drawable.mad
        };
        RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        recyclerView.setAdapter(new CarViewAdapter(this, resIds));
        int spacing = MainActivity.this.getResources().getDimensionPixelOffset(R.dimen.recycler_view_spacing);
        recyclerView.addItemDecoration(new CarViewAdapter.CarItemDecoration(spacing));
    }
}
